package light.head.model.el;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.hibernate.annotations.Formula;
/**
 * 考试记录表
 */
@Table
@Entity
public class ExamRecord implements Serializable{
	
	private static final long serialVersionUID = 7702459794776718278L;
	private Integer code;			// 流水号
	private Integer clc;			// 班级编号 
	private Integer cc;				// 课程编号
	private Float examScore;		// 考试得分
	private Integer oc;				// 创建机构
	private Integer cu;				// 创建人
	private Date ct;				// 创建时间
	private Boolean deleted = false;// 是否删除
	private Boolean isMark = false;	// 是否需要阅卷
	private Integer markCu;			// 最后阅卷人
	private Date markCt;			// 最后阅卷时间
	
	private List<TopicRecord> trList;	//考题记录
	private String ccn;				// 课程名称
	private Boolean isPass;			// 是否通过
	private String markCun;			// 阅卷人
	private String clcn;			// 班级名称
	private String on;
	private String cn;
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column
	public Integer getCode() {
		return code;
	}
	@Column
	public Integer getClc() {
		return clc;
	}
	@Column
	public Integer getCc() {
		return cc;
	}
	@Column
	public Float getExamScore() {
		return examScore;
	}
	@Column
	public Integer getOc() {
		return oc;
	}
	@Column(updatable = false, nullable = false)
	public Integer getCu() {
		return cu;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column(updatable = false, nullable = false)
	public Date getCt() {
		return ct;
	}
	@Column
	public Boolean getDeleted() {
		return deleted;
	}
	@Column
	public Boolean getIsMark() {
		return isMark;
	}
	@Column
	public Integer getMarkCu() {
		return markCu;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column
	public Date getMarkCt() {
		return markCt;
	}
	@Formula("(SELECT c.name FROM Course c WHERE c.code = cc)")
	public String getCcn() {
		return ccn;
	}
	@Formula("(SELECT c.name FROM Classes c WHERE c.code = clc)")
	public String getClcn() {
		return clcn;
	}
	@Formula("(SELECT o.name FROM Organ o WHERE o.code = oc)")
	public String getOn() {
		return on;
	}
	@Formula("(SELECT ui.realName FROM UserInfo ui WHERE ui.code = cu)")
	public String getCn() {
		return cn;
	}
	// 查询学员这次考试是否通过
	@Formula("(CASE WHEN examScore >= (SELECT ccr.qualifiedSocre FROM ClassesCourseRelation ccr WHERE ccr.clc = clc AND ccr.cc = cc) THEN 1 ELSE 0 END)")
	public Boolean getIsPass() {
		return isPass;
	}
	@Formula("(SELECT ui.realName FROM UserInfo ui WHERE ui.code = markCu)")
	public String getMarkCun() {
		return markCun;
	}
	@Transient
	public List<TopicRecord> getTrList() {
		return trList;
	}
	
	
	
	
	
	
	
	public void setCn(String cn) {
		this.cn = cn;
	}
	public void setOn(String on) {
		this.on = on;
	}
	public void setClcn(String clcn) {
		this.clcn = clcn;
	}
	public void setCode(Integer code) {
		this.code = code;
	}
	public void setClc(Integer clc) {
		this.clc = clc;
	}
	public void setCc(Integer cc) {
		this.cc = cc;
	}
	public void setExamScore(Float examScore) {
		this.examScore = examScore;
	}
	public void setIsPass(Boolean isPass) {
		this.isPass = isPass;
	}
	public void setOc(Integer oc) {
		this.oc = oc;
	}
	public void setCu(Integer cu) {
		this.cu = cu;
	}
	public void setCt(Date ct) {
		this.ct = ct;
	}
	public void setDeleted(Boolean deleted) {
		this.deleted = deleted;
	}
	public void setIsMark(Boolean isMark) {
		this.isMark = isMark;
	}
	public void setMarkCu(Integer markCu) {
		this.markCu = markCu;
	}
	public void setMarkCt(Date markCt) {
		this.markCt = markCt;
	}
	public void setCcn(String ccn) {
		this.ccn = ccn;
	}
	public void setMarkCun(String markCun) {
		this.markCun = markCun;
	}
	public void setTrList(List<TopicRecord> trList) {
		this.trList = trList;
	}
}
